#Set doc0 = CATIA.Documents.Add("Part")
#Debug.Print CATIA.ActiveDocument.Name
from win32com.client import Dispatch

CATIA = Dispatch("CATIA.Application")
if CATIA.ActiveDocument.Name.find("CATPart") > 0:
    p = CATIA.ActiveDocument.Part
else:
    #product1 = CATIA.ActiveDocument.product
    doc0 = CATIA.Documents.Open("test_model\\original.CATProduct")
    product1 = CATIA.ActiveDocument.Product
    p2 = product1.Products.Item(2)
    p = p2.ReferenceProduct.Parent.Part    
    # p = doc0.Part
D = p.GetCustomerFactory("CAAIATestInterfaceVB")
#s1 = D.CreateSprocket("test_1")
#D.TestFunction("hello")
#A = "123"
#A = D.OutputName
#print(A)
